from selenium import webdriver
from selenium.webdriver import ActionChains
from time import sleep

browser = webdriver.Chrome('D:\\资料\\第六个月\\chromedriver.exe')
browser.get('http://localhost:8080/newlog')
sleep(1)
browser.find_elements_by_tag_name('input')[1].send_keys('xiaobai1')  # 用户名的添加
sleep(1)
browser.find_elements_by_tag_name('input')[2].send_keys('123')  # 密码的添加
sleep(1)
# 定义拖动对象
button = browser.find_element_by_class_name('dv_handler')
box = browser.find_element_by_class_name('dv_text')
# 定义动作对象
action = ActionChains(browser)
action.click_and_hold(button).perform()
# 释放动作
action.reset_actions()
square_len = button.size.get('width')  # 获取按钮条长度
box_len = box.size.get('width')  # 获取按钮条长度
action.move_by_offset(box_len - square_len, 0).perform()  #拖动按钮条
sleep(1)
browser.find_element_by_class_name('h-btn').click()


sleep(2)
browser.close()